using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Designer.Interfaces;
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Xml;
using System.Diagnostics;

using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
using IServiceProvider = System.IServiceProvider;

namespace MH.WsdlWorks
{
    [CLSCompliant(false), ComVisible(true)]
    public class SimpleSingleFileGeneratorNodeProperties : SimpleFileNodeProperties
    {
        #region fields
        private EventHandler<SimpleHierarchyNodeEventArgs> onCustomToolChanged;
        private EventHandler<SimpleHierarchyNodeEventArgs> onCustomToolNameSpaceChanged;
        protected string customTool = "";
        protected string customToolNamespace = "";

        #endregion

        #region custom tool events
        internal event EventHandler<SimpleHierarchyNodeEventArgs> OnCustomToolChanged
        {
            add { onCustomToolChanged += value; }
            remove { onCustomToolChanged -= value; }
        }

        internal event EventHandler<SimpleHierarchyNodeEventArgs> OnCustomToolNameSpaceChanged
        {
            add { onCustomToolNameSpaceChanged += value; }
            remove { onCustomToolNameSpaceChanged -= value; }
        }

        #endregion

        #region properties
        [SRCategoryAttribute(SR.Advanced)]
        [Microsoft.VisualStudio.Package.LocDisplayName(SR.CustomTool)]
        [SRDescriptionAttribute(SR.CustomToolDescription)]
        public virtual string CustomTool
        {
            get
            {
                customTool = this.Node.ItemNode.GetMetadata(ProjectFileConstants.Generator);
                return customTool;
            }
            set
            {
                customTool = value;
                if (!string.IsNullOrEmpty(customTool))
                {
                    this.Node.ItemNode.SetMetadata(ProjectFileConstants.Generator, customTool);
                    SimpleHierarchyNodeEventArgs args = new SimpleHierarchyNodeEventArgs(this.Node);
                    if (onCustomToolChanged != null)
                    {
                        onCustomToolChanged(this.Node, args);
                    }
                }
            }
        }

        [SRCategoryAttribute(Microsoft.VisualStudio.Package.SR.Advanced)]
        [Microsoft.VisualStudio.Package.LocDisplayName(SR.CustomToolNamespace)]
        [SRDescriptionAttribute(SR.CustomToolNamespaceDescription)]
        public virtual string CustomToolNamespace
        {
            get
            {
                customToolNamespace = this.Node.ItemNode.GetMetadata(ProjectFileConstants.CustomToolNamespace);
                return customToolNamespace;
            }
            set
            {
                customToolNamespace = value;
                if (!string.IsNullOrEmpty(customToolNamespace))
                {
                    this.Node.ItemNode.SetMetadata(ProjectFileConstants.CustomToolNamespace, customToolNamespace);
                    SimpleHierarchyNodeEventArgs args = new SimpleHierarchyNodeEventArgs(this.Node);
                    if (onCustomToolNameSpaceChanged != null)
                    {
                        onCustomToolNameSpaceChanged(this.Node, args);
                    }
                }
            }
        }
        #endregion

        #region ctors
        public SimpleSingleFileGeneratorNodeProperties()
        {
        }

        public SimpleSingleFileGeneratorNodeProperties(SimpleHierarchyNode node)
            : base(node)
        {
        }
        #endregion
    }
}
